$(function () {

});

function searchData() {
    var table = layui.table, layer = layui.layer;

    table.init('serviceTable',{
        data: [
            {
                id:1,
                "GMSFZHM" : "440221********0622",
                "HJDZ" : "广东省韶关市曲江区****",
                "XZJDMC" : "",
                "PCH" : "",
                "SSXQMC" : "",
                "XM" : "李四",
                "PCSMC" : "",
                "JGSSX" : "广东省韶关市曲江区****",
                "CSRQ" : "",
                "XB" : "男",
                "CYM" : "",
                "MZ" : "汉",
                "CSDXZ" : "",
                "RKSJ" : "",
                "JLXMC" : ""
            }
        ]
        , toolbar: true
        , title: '广东省居住证基本信息'
        , page: true
    });

    //监听行工具事件
    table.on('tool(serviceTable)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
        var data = obj.data //获得当前行数据
            , layEvent = obj.event; //获得 lay-event 对应的值

        if (layEvent === 'detail') {
            loadDetail(data.id)
        }
    });
}

function loadDetail(id) {
    var data = [
        {
            id:1,
            "GMSFZHM" : "440221********0622",
            "HJDZ" : "广东省韶关市曲江区****",
            "XZJDMC" : "",
            "PCH" : "",
            "SSXQMC" : "",
            "XM" : "李四",
            "PCSMC" : "",
            "JGSSX" : "广东省韶关市曲江区****",
            "CSRQ" : "",
            "XB" : "男",
            "CYM" : "",
            "MZ" : "汉",
            "CSDXZ" : "",
            "RKSJ" : "",
            "JLXMC" : ""
        }
    ];


    var data0 = data[parseInt(id) - 1]
    $('#detailD').html(template('detailDS',{data:data0}));
    layer.open({
        type: 1,
        content: $("#detail"),
        area: ['900px', '550px'],
        title: '广东省居住证基本信息详情',
        maxmin: true,
        shade: 0,
        cancel: function () {
            $("#detail").hide()
        }
    });


}